<?php

namespace app\admin\model;

use think\Model;

class Menu extends Model
{
    protected $schema = [
        'id' => 'int',
        'type' => 'int',
        'parent_id' => 'int',
        'title' => 'string',
        'icon' => 'string',
        'url' => 'string',
        'node' => 'string',
        'param' => 'string',
        'display' => 'int',
        'status' => 'int',
        'create_time' => 'timestamp',
        'update_time' => 'timestamp',
    ];

    public function getTypeAttr($value)
    {       
        $type = [1 => '系统菜单', 2 => '店铺菜单'];
        return $type[$value];
    }

    public function Roles()
    {
        return $this->belongsToMany(Role::class,RoleMenu::class);
    }

    public function Role()
    {
        return $this->belongsTo(Role::class,RoleMenu::class);
    }

}